<?php
	class loaispdb
	{
		public function Add($TenLoai)
		{
			$sql = "INSERT INTO `tbl_loaisp`(`TenLoai`) 
			VALUES (".dataservice::slashes($TenLoai).")";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Delete($MaLoai)
		{
			$sql = "DELETE FROM `tbl_loaisp` WHERE MaLoai = '$MaLoai'";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Update($MaLoai, $TenLoai)
		{
			$sql = "UPDATE `tbl_loaisp` SET TenLoai = ".dataservice::slashes($TenLoai)." WHERE MaLoai = '$MaLoai'"; 
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
	
		public function GetList($MaLoai, $TenLoai)
		{
			$sql = "SELECT * FROM `tbl_loaisp` WHERE 1";
			if($MaLoai!="")
				$sql .= " AND MaLoai = '$MaLoai' ";
			if($TenLoai!="")
				$sql .= " AND TenLoai LIKE '%$TenLoai%' ";
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		public function Find($TenLoai)
		{
			$sql = "SELECT * FROM `tbl_loaisp` WHERE 1";
			if($TenLoai!="")
				$sql = " SELECT * FROM `tbl_loaisp` WHERE TenLoai LIKE '%$TenLoai%' ";
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
	}
?>